{layout name="layout_dialog" /}
<div class="layui-form" id="menu_add">
    <div class="layui-form-item">
        <div class="layui-upload-drag" id="test10">
            <i class="layui-icon"></i>
            <p>点击上传，或将文件拖拽到此处</p>
            <div class="layui-hide" id="uploadDemoView">
                <hr>
                <img src="" alt="上传成功后渲染" style="max-width: 196px">
            </div>
        </div>
    </div>
</div>
<script>

layui.use(['upload', 'element', 'layer'], function() {
    var $ = layui.jquery
        , upload = layui.upload
        , layer = layui.layer;
    //自适应宽高
    var index = parent.layer.getFrameIndex(window.name);
    parent.layer.iframeAuto(index);

    //拖拽上传
    upload.render({
        elem: '#test10'
        ,url: '/admin/root/upload/id/'+{$editId} //此处用的是第三方的 http 请求演示，实际使用时改成您自己的上传接口即可。
        ,done: function(res){
            layer.msg('上传成功,请刷新页面');
            layui.$('#uploadDemoView').removeClass('layui-hide').find('img').attr('src',res.data);
            var index = parent.layer.getFrameIndex(window.name);
            parent.layer.iframeAuto(index);
            //刷新父页面
            //parent.window.location.reload();
            console.log(res)
        }
    });

});

</script>